#ifndef TVIMEG_MEDIA_INFO_H
#define TVIMEG_MEDIA_INFO_H

#include <MediaInfo/MediaInfo.h>

namespace Tvimeg
{
	class File;

	class MediaInfo
	{
	public:
		MediaInfo(const File& fileIn);

		const std::string&	GetContainerFormat(void) const	{ return containerFormat; }
		int					GetDuration(void) const			{ return duration; }

		const std::string&	GetVideoFormat(void) const		{ return videoFormat; }
		int					GetWidth(void) const			{ return width; }
		int					GetHeight(void) const			{ return height; }
		float				GetAspectRatio(void) const		{ return aspectRatio; }
		float				GetFrameRate(void) const		{ return frameRate; }

		const std::string&	GetAudioFormat(void) const		{ return audioFormat; }
		int					GetChannels(void) const			{ return channels; }

	private:
		static void			Initialise(void);

		static void			ConvertUTF16ToUTF8(const std::wstring& stringIn, std::string& stringOut);
		static void			ConvertUTF8ToUTF16(const std::string& stringIn, std::wstring& stringOut);

		static int			ConvertToInt(const std::wstring& stringIn);
		static float		ConvertToFloat(const std::wstring& stringIn);

		bool				NeedsInfo(void) const;
		bool				GetInfo(MediaInfoLib::MediaInfo& info);

		static void			GetInt(MediaInfoLib::MediaInfo& info, const MediaInfoLib::stream_t stream, const std::wstring& name, int& value);
		static void			GetFloat(MediaInfoLib::MediaInfo& info, const MediaInfoLib::stream_t stream, const std::wstring& name, float& value);
		static void			GetString(MediaInfoLib::MediaInfo& info, const MediaInfoLib::stream_t stream, const std::wstring& name, std::string& value);

		File				file;

		std::string			containerFormat;
		int					duration;

		std::string			videoFormat;
		int					width;
		int					height;
		float				aspectRatio;
		float				frameRate;

		std::string			audioFormat;
		int					channels;
	};
}

#endif // TVIMEG_MEDIA_INFO_H
